#include "visual_scop.h"

#ifdef ENABLE_Visual_Scop_Show
void Hal_Visual_Scop_Send(uint8 *pdat,uint8 num)
{
  uint8 i;
  for(i=0;i<num;i++)
  {
		//Debug_Uart_SpiUartWriteTxData(*(pdat+i));

		//Debug_Uart_UartPutChar(*(pdat+i));
    
    SW_Tx_UART_PutChar(*(pdat+i));
  }
}



uint16 CRC_Check(uint8 *pdat, uint8 CRC_num)
{
    uint16 CRC_Temp;
    uint8 i,j;
    CRC_Temp = 0xffff;
    
    for (i=0;i<CRC_num; i++)
    {      
        CRC_Temp ^= *(pdat+i);
        for (j=0;j<8;j++) 
        {
            if (CRC_Temp & 0x01)
                CRC_Temp = (CRC_Temp >>1 ) ^ 0xa001;
            else
                CRC_Temp = CRC_Temp >> 1;
        }
    }
    return(CRC_Temp);
}

void Visual_Scop_Show(int CH1,int CH2,int CH3,int CH4)
{
    uint16 databuf[5];
    databuf[0]=CH1;
    databuf[1]=CH2;
    databuf[2]=CH3;
    databuf[3]=CH4;
    databuf[4] = CRC_Check((uint8 *)databuf,8);
    Hal_Visual_Scop_Send((uint8 *)databuf,10);
}

void Visual_Scop_Start(void)
{

	//Debug_Uart_Start();
  SW_Tx_UART_Start();
}


#endif


